package com.example.strategy;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Risky57 on 2017/4/28.
 */

public class StrategyDemo {

    public static void main (String[] args) {

        Duck d1 = new RedHeadDuck();
        Duck d2 = new GreenDuck();
        Duck d3 = new RubberDuck();
        List<Duck> ducks = new ArrayList<>();
        ducks.add(d1);
        ducks.add(d2);
        ducks.add(d3);
        sport(ducks);
        d3.setFlyBehavior(new FlyWithRocket());
        sport(ducks);

    }

    public static void sport(List<Duck> ducks){

        for (Duck duck : ducks) {
            duck.display();
            duck.swimming();
            duck.fly();
        }

    }


}
